package com.zhangy.controller;
import com.zhangy.model.Xiezilou;
import com.zhangy.service.XiezilouService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

@CrossOrigin
@Transactional
@Controller
@ResponseBody
public class XiezilouController {
    @Autowired
    private XiezilouService xiezilouService ;

    @RequestMapping("addXiezilou")
    public void addXiezilou(Xiezilou xiezilou){
        xiezilouService.addXiezilou(xiezilou);
    }
    @RequestMapping("delXiezilou")
    public void delXiezilou(String ids){
        String[] split = ids.split(",");
        List<Integer> arrList=new ArrayList<Integer>();
        for (String idd: split) {
            arrList.add(Integer.parseInt(idd));
        }
        xiezilouService.delXiezilou(arrList);
    }
    @RequestMapping("selXiezilouById")
    public Xiezilou selXiezilouById(int zxid){
        return xiezilouService.selXiezilouById(zxid);
    }
    @RequestMapping("updateXiezilou")
    public void updateXiezilou(Xiezilou xiezilou){
        xiezilouService.updateXiezilou(xiezilou);
    }
    @RequestMapping("selectXiezilou")
    public List<Xiezilou> selectXiezilou(){
        return xiezilouService.selectXiezilou();
    }
}
